using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Threading;
using System.Web.Mvc;
using ThreadPoolManage;
using ThreadManage;
using ThreadManage.Event;


namespace UMS.OA.TestProject.Event
{
    public class TestEvent_YB
    {
        string guid = Guid.NewGuid().ToString();
        string guid2 = Guid.NewGuid().ToString();
        string guid3 = Guid.NewGuid().ToString();
        string guid1 = Guid.NewGuid().ToString();
        string guid4 = Guid.NewGuid().ToString();
        string guid5 = Guid.NewGuid().ToString();
        string guid6 = Guid.NewGuid().ToString();
        public object ThreadTest()
        {
            /* 
             1.验证单例  √
             2.验证单线程报错是否会影响到其他线程  √
             3.验证各队列和统计数据的正确性  √
             4.验证各get、set √
             5.验证对线程的操作  √
             6.验证进度相关  √
             7.验证其他方法 正则 日志√
             8.验证id的传递（是否会在某个环节移除后被某个代码段使用）√
             9.多线程注意脏写、脏读、不可重复读和幻读啥的 √
             */
            //调用一个线程
            //object param3 = "10";
            //var task_obj3 = ThreadPoolManager.getInstance();
            //string result3 = task_obj3.AddTaskItem(new WaitCallback(Test), null, guid);
            //Dictionary<string, int> getPoolState3 = task_obj3.GetPoolState();

            //object param = "10";
            //var task_obj = ThreadPoolManager.getInstance();
            //string result = task_obj.AddTaskItem(new WaitCallback(Test), null, guid3);
            //Dictionary<string, int> getPoolState = task_obj.GetPoolState();

            //object param2 = "10|";
            //var task_obj2 = ThreadPoolManager.getInstance(1, 5, 1);
            //string result2= task_obj2.AddTaskItem(new WaitCallback(Test), null, guid2);
            //Dictionary<string, int> getPoolState2 = task_obj2.GetPoolState();

            //object param1 = "10|";
            //var task_obj1 = ThreadPoolManager.getInstance(1, 5, 1);
            //string result1 = task_obj1.AddTaskItem(new WaitCallback(Test), null, guid1);
            //Dictionary<string, int> getPoolState1 = task_obj1.GetPoolState();

            //object param4 = "10|";
            //var task_obj4 = ThreadPoolManager.getInstance(1, 5, 1);
            //string result4 = task_obj4.AddTaskItem(new WaitCallback(Test), null, guid4);
            //Dictionary<string, int> getPoolState4 = task_obj4.GetPoolState();

            //object param5 = "10|";
            //var task_obj5 = ThreadPoolManager.getInstance(1, 5, 1);
            //string result5 = task_obj5.AddTaskItem(new WaitCallback(Test), null, guid5);
            //Dictionary<string, int> getPoolState5 = task_obj5.GetPoolState();

            //object param6 = "10|";
            //var task_obj6 = ThreadPoolManager.getInstance(1, 5, 1);
            //string result6 = task_obj6.AddTaskItem(new WaitCallback(Test), null, guid6);
            //Dictionary<string, int> getPoolState6 = task_obj6.GetPoolState();
            return null;
        }

        public void Test7()
        {
           
             System.Diagnostics.Debug.WriteLine("回调成功");

        }
        public void Test6(object s)
        {
            //ThreadPoolManager.getInstance().AddTaskProgress(guid, 66, 100);
            for (int i = 0; i < 10000; i++)
            {
                if (i % 100 == 0 && i != 0)
                {
                    // ThreadPoolManager.getInstance().AddTaskProgress(guid,i,100);
                    System.Diagnostics.Debug.WriteLine(i + "有参无返回6");
                }
            }
        }
        public string Test(object jindu) {
            //ThreadPoolManager.getInstance().AddTaskProgress(guid, 66, 100);
            for (int i=0;i<10000;i++)
            {
                if (i%100==0&&i!=0)
                {
                   // ThreadPoolManager.getInstance().AddTaskProgress(guid,i,100);
                    System.Diagnostics.Debug.WriteLine(i+ "有参有返回");
                }
            }
            return "返回";
        }
        public string Test4()
        {
            //ThreadPoolManager.getInstance().AddTaskProgress(guid, 66, 100);
            for (int i = 0; i < 10000; i++)
            {
                if (i % 100 == 0 && i != 0)
                {
                   //ThreadPoolManager.getInstance().AddTaskProgress(guid, i, 100);
                    System.Diagnostics.Debug.WriteLine(i + "无参有返回4");
                }
            }
            return "返回";
        }
        public void Test5()
        {
            //ThreadPoolManager.getInstance().AddTaskProgress(guid, 66, 100);
            for (int i = 0; i < 10000; i++)
            {
                if (i % 100 == 0 && i != 0)
                {
                    //ThreadPoolManager.getInstance().AddTaskProgress(guid, i, 100);
                    System.Diagnostics.Debug.WriteLine(i + "无参无返回5");
                }
            }
        }
        public void Test2(object jindu)
        {
            System.Diagnostics.Debug.WriteLine("报错2"+ jindu);
            throw new DivideByZeroException();
            //ThreadPoolManager.getInstance().AddTaskProgress(guid2, 12, 100);
        }
        public object Test3(object s)
        {
            System.Diagnostics.Debug.WriteLine("有参有返回3");
            return s;
        }
        #endregion
    }
}
